import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 28779
 * Date: 2024-03-09
 * Time: 16:39
 */
@WebServlet("/setCookie")
public class setCookieServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Cookie cookie = new Cookie("data","2024-3-9");
        resp.addCookie(cookie);
        Cookie cookie2 = new Cookie("time","16:45");
        resp.addCookie(cookie2);
        resp.getWriter().write("setCookie  ok");
    }
}